package main

import (
	"log"
	"net/http"
)

func runWebListener() {
	http.HandleFunc("/", handleStaticFile)

	http.HandleFunc("/spell/GetDialogArgs.html", handleGetSpellDialogArgs)
	http.HandleFunc("/spell/GetEnumType.html", handleGetSpellEnumType)
	http.HandleFunc("/spell/GetUIView.html", handleGetSpellUIView)
	http.HandleFunc("/spell/GetTreeView.html", handleGetSpellTreeView)
	http.HandleFunc("/spell/SaveTreeView.html", handleSaveSpellTreeView)
	http.HandleFunc("/spell/GetInstance.html", handleGetSpellInstance)
	http.HandleFunc("/spell/NewInstance.html", handleNewSpellInstance)
	http.HandleFunc("/spell/CopyInstance.html", handleCopySpellInstance)
	http.HandleFunc("/spell/DeleteInstance.html", handleDeleteSpellInstance)
	http.HandleFunc("/spell/SaveInstance.html", handleSaveSpellInstance)
	http.HandleFunc("/spell/GetLevelInstance.html", handleGetSpellLevelInstance)
	http.HandleFunc("/spell/NewLevelInstance.html", handleNewSpellLevelInstance)
	http.HandleFunc("/spell/CopyLevelInstance.html", handleCopySpellLevelInstance)
	http.HandleFunc("/spell/DeleteLevelInstance.html", handleDeleteSpellLevelInstance)
	http.HandleFunc("/spell/GetLevelEffectInstance.html", handleGetSpellLevelEffectInstance)
	http.HandleFunc("/spell/NewLevelEffectInstance.html", handleNewSpellLevelEffectInstance)
	http.HandleFunc("/spell/CopyLevelEffectInstance.html", handleCopySpellLevelEffectInstance)
	http.HandleFunc("/spell/DeleteLevelEffectInstance.html", handleDeleteSpellLevelEffectInstance)

	http.HandleFunc("/quest/GetTemplates.html", handleGetQuestTemplates)
	http.HandleFunc("/quest/GetDialogArgs.html", handleGetQuestDialogArgs)
	http.HandleFunc("/quest/GetEnumType.html", handleGetQuestEnumType)
	http.HandleFunc("/quest/GetUIView.html", handleGetQuestUIView)
	http.HandleFunc("/quest/GetTreeView.html", handleGetQuestTreeView)
	http.HandleFunc("/quest/SaveTreeView.html", handleSaveQuestTreeView)
	http.HandleFunc("/quest/GetInstance.html", handleGetQuestInstance)
	http.HandleFunc("/quest/NewInstance.html", handleNewQuestInstance)
	http.HandleFunc("/quest/CopyInstance.html", handleCopyQuestInstance)
	http.HandleFunc("/quest/DeleteInstance.html", handleDeleteQuestInstance)
	http.HandleFunc("/quest/SaveInstance.html", handleSaveQuestInstance)

	http.HandleFunc("/char/GetDialogArgs.html", handleGetCharDialogArgs)
	http.HandleFunc("/char/GetEnumType.html", handleGetCharEnumType)
	http.HandleFunc("/char/GetUIView.html", handleGetCharUIView)
	http.HandleFunc("/char/GetTreeView.html", handleGetCharTreeView)
	http.HandleFunc("/char/SaveTreeView.html", handleSaveCharTreeView)
	http.HandleFunc("/char/GetInstance.html", handleGetCharInstance)
	http.HandleFunc("/char/NewInstance.html", handleNewCharInstance)
	http.HandleFunc("/char/CopyInstance.html", handleCopyCharInstance)
	http.HandleFunc("/char/DeleteInstance.html", handleDeleteCharInstance)
	http.HandleFunc("/char/SaveInstance.html", handleSaveCharInstance)

	http.HandleFunc("/sobj/GetTemplates.html", handleGetSObjTemplates)
	http.HandleFunc("/sobj/GetDialogArgs.html", handleGetSObjDialogArgs)
	http.HandleFunc("/sobj/GetEnumType.html", handleGetSObjEnumType)
	http.HandleFunc("/sobj/GetTreeView.html", handleGetSObjTreeView)
	http.HandleFunc("/sobj/SaveTreeView.html", handleSaveSObjTreeView)
	http.HandleFunc("/sobj/GetInstance.html", handleGetSObjInstance)
	http.HandleFunc("/sobj/NewInstance.html", handleNewSObjInstance)
	http.HandleFunc("/sobj/CopyInstance.html", handleCopySObjInstance)
	http.HandleFunc("/sobj/DeleteInstance.html", handleDeleteSObjInstance)
	http.HandleFunc("/sobj/SaveInstance.html", handleSaveSObjInstance)

	http.HandleFunc("/item/GetDialogArgs.html", handleGetItemDialogArgs)
	http.HandleFunc("/item/GetEnumType.html", handleGetItemEnumType)
	http.HandleFunc("/item/GetUIView.html", handleGetItemUIView)
	http.HandleFunc("/item/GetTreeView.html", handleGetItemTreeView)
	http.HandleFunc("/item/SaveTreeView.html", handleSaveItemTreeView)
	http.HandleFunc("/item/GetInstance.html", handleGetItemInstance)
	http.HandleFunc("/item/NewInstance.html", handleNewItemInstance)
	http.HandleFunc("/item/CopyInstance.html", handleCopyItemInstance)
	http.HandleFunc("/item/DeleteInstance.html", handleDeleteItemInstance)
	http.HandleFunc("/item/SaveInstance.html", handleSaveItemInstance)

	http.HandleFunc("/loot/GetDialogArgs.html", handleGetLootDialogArgs)
	http.HandleFunc("/loot/GetUIView.html", handleGetLootUIView)
	http.HandleFunc("/loot/GetTreeView.html", handleGetLootTreeView)
	http.HandleFunc("/loot/SaveTreeView.html", handleSaveLootTreeView)
	http.HandleFunc("/loot/GetInstance.html", handleGetLootInstance)
	http.HandleFunc("/loot/NewInstance.html", handleNewLootInstance)
	http.HandleFunc("/loot/CopyInstance.html", handleCopyLootInstance)
	http.HandleFunc("/loot/DeleteInstance.html", handleDeleteLootInstance)
	http.HandleFunc("/loot/SaveInstance.html", handleSaveLootInstance)
	http.HandleFunc("/loot/GetGroupInstance.html", handleGetLootGroupInstance)
	http.HandleFunc("/loot/NewGroupInstance.html", handleNewLootGroupInstance)
	http.HandleFunc("/loot/CopyGroupInstance.html", handleCopyLootGroupInstance)
	http.HandleFunc("/loot/DeleteGroupInstance.html", handleDeleteLootGroupInstance)
	http.HandleFunc("/loot/GetGroupItemInstance.html", handleGetLootGroupItemInstance)
	http.HandleFunc("/loot/NewGroupItemInstance.html", handleNewLootGroupItemInstance)
	http.HandleFunc("/loot/CopyGroupItemInstance.html", handleCopyLootGroupItemInstance)
	http.HandleFunc("/loot/DeleteGroupItemInstance.html", handleDeleteLootGroupItemInstance)
	http.HandleFunc("/loot/GetGroupChequeInstance.html", handleGetLootGroupChequeInstance)
	http.HandleFunc("/loot/NewGroupChequeInstance.html", handleNewLootGroupChequeInstance)
	http.HandleFunc("/loot/CopyGroupChequeInstance.html", handleCopyLootGroupChequeInstance)
	http.HandleFunc("/loot/DeleteGroupChequeInstance.html", handleDeleteLootGroupChequeInstance)

	err := http.ListenAndServe(cfg.WebListen, nil)
	if err != http.ErrServerClosed {
		log.Fatalf("listen web `%s` failed, %s.\n", cfg.WebListen, err)
	}
}
